package com.example.travelapplication.fragment;

import android.os.Bundle;

import androidx.fragment.app.Fragment;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.example.travelapplication.R;

/**
 * A simple {@link Fragment} subclass.
 * Use the {@link FragmentAbout#newInstance} factory method to
 * create an instance of this fragment.
 */
public class FragmentAbout extends Fragment {

    // TODO: Rename parameter arguments, choose names that match
    // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
    private static final String ARG_PARAM1 = "param1";
    private static final String ARG_PARAM2 = "param2";

    // TODO: Rename and change types of parameters
    private String mParam1;
    private String mParam2;

    public FragmentAbout() {
        // Required empty public constructor
    }

    /**
     * Use this factory method to create a new instance of
     * this fragment using the provided parameters.
     *
     * @param param1 Parameter 1.
     * @param param2 Parameter 2.
     * @return A new instance of fragment FragmentAbout.
     */
    // TODO: Rename and change types and number of parameters
    public static FragmentAbout newInstance(String param1, String param2) {
        FragmentAbout fragment = new FragmentAbout();
        Bundle args = new Bundle();
        args.putString(ARG_PARAM1, param1);
        args.putString(ARG_PARAM2, param2);
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (getArguments() != null) {
            mParam1 = getArguments().getString(ARG_PARAM1);
            mParam2 = getArguments().getString(ARG_PARAM2);
        }
    }

    TextView tv_contnet;
    TextView tv_title;
    TextView tv_app_version;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View view = inflater.inflate(R.layout.fragment_about, container, false);

        tv_app_version = view.findViewById(R.id.tv_app_version);
        tv_contnet = view.findViewById(R.id.tv_about_content);
        tv_title = view.findViewById(R.id.tv_about_title);

        String appName = getResources().getString(R.string.app_name);
        String title = appName + "介绍：";
        String content = appName + " 是您旅行的理想伙伴！无论您是计划一次冒险之旅还是寻找放松度假， " + appName + " 都能满足您的需求。" +
                "通过 " + appName + " ，您可以轻松地查找目的地、预订机票和酒店、探索当地景点和活动，并与其他旅行者分享您的经历和建议。" +
                "无论您身在何处， " + appName + " 都能为您提供个性化的旅行建议和实时支持，让您的旅行更加轻松、愉快！";

        String version = "Version 1.0.0";

        tv_title.setText(title);
        tv_contnet.setText(content);
        tv_app_version.setText(version);

        return view;
    }
}